FROM registry.cn-beijing.aliyuncs.com/hub-mirrors/openjdk:17-jdk-alpine

# 设置环境变量
ARG AI_API_KEY="sk-xxx"
ARG SERVER_PORT=8080

ENV AI_API_KEY ${AI_API_KEY}
ENV SERVER_PORT ${SERVER_PORT}

RUN mkdir -p /root/appstack/ai-demo
WORKDIR /root/appstack

# 拷贝解压项目
COPY target/spring-cloud-ai-example-0.0.1-SNAPSHOT.jar /root/appstack/ai-demo/spring-cloud-ai-example.jar

RUN echo "java -jar /root/appstack/ai-demo/spring-cloud-ai-example.jar > /root/appstack/ai-demo/application.log 2>&1" > /root/appstack/start.sh
RUN chmod +x /root/appstack/start.sh

ENTRYPOINT ["/bin/sh", "/root/appstack/start.sh"]